package com.sdry.product.prod.controller;

import com.sdry.common.BaseController;
import com.sdry.common.TableDataInfo;
import com.sdry.exception.BizException;
import com.sdry.exception.CommonEnum;
import com.sdry.product.prod.entity.LacquerInto;
import com.sdry.product.prod.entity.ProductHandleOut;
import com.sdry.product.prod.service.LacquerIntoService;
import net.bytebuddy.implementation.bytecode.Throw;
import net.sf.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (喷漆线)表控制层
 *
 * @author makejava
 * @since 2020-03-04 13:57:35
 */
@Controller
@RequestMapping(value = "lacquerInto")
public class LacquerIntoController extends BaseController {

    /**
     * 服务对象
     */
    @Resource
    private LacquerIntoService lacquerIntoService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public LacquerInto selectOne(Long id) {
        return this.lacquerIntoService.queryById(id);
    }

    /**
     * 展示
     * @return
     */
    @RequestMapping(value = "showLacquerInto")
    public String showLacquerInto() {
        return "/product/prod/lacquerInto";
    }

    /**
     * 展示
     * @return
     */
    @RequestMapping(value = "showLacquerIntoOut")
    public String showLacquerIntoOut() {
        return "/product/prod/lacquerIntoOut";
    }


    /**
     * 分页查询喷漆线上线表
     * @param lacquerInto 喷漆线
     * @return TableDataInfo
     */
    @RequestMapping(value = "queryLacquerIntoPage")
    @ResponseBody
    public TableDataInfo queryLacquerIntoPage(LacquerInto lacquerInto) {
        logger.info("分页查询喷漆线上线表  lacquerInto = {} "+ JSONArray.fromObject(lacquerInto));
        try {
            List<LacquerInto> lacquerIntoList = lacquerIntoService.queryLacquerIntoPage(lacquerInto);
            Long total = lacquerIntoService.queryLacquerIntoTotal(lacquerInto);
            return getDataTable(lacquerIntoList,total);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTableError();
        }
    }
}